from playwright.sync_api import Playwright, sync_playwright
def run(playwright: Playwright) -> None:
    browser = playwright.chromium.launch(headless=False)
    context = browser.new_context()
    # Open new page
    page = context.new_page()
    # Go to https://dohko.login.internal.tiaofangzi.com/login?redirectURL=http%3A%2F%2Fpublic-mis.tiaofangzi.com
    page.goto("https://dohko.login.internal.tiaofangzi.com/login?redirectURL=http%3A%2F%2Fpublic-mis.tiaofangzi.com")
    # Click text=手机登录
    page.click("text=手机登录")
    # Fill [placeholder="手机号"]
    page.fill("[placeholder=\"手机号\"]", "13269082272")
    # Press Tab
    page.press("[placeholder=\"手机号\"]", "Tab")
    # Fill [placeholder="动态密码"]
    page.fill("[placeholder=\"动态密码\"]", "000000")
    # Click button:has-text("登 录")
    # with page.expect_navigation(url="https://public-mis.tiaofangzi.com/#/"):
    with page.expect_navigation():
        page.click("button:has-text(\"登 录\")")
    # Click text=商户
    page.click("text=商户")
    # Click a:has-text("集团列表")
    page.click("a:has-text(\"集团列表\")")
    # assert page.url == "https://public-mis.tiaofangzi.com/#/groupMerchant"
    # Click button:has-text("查询")
    page.click("button:has-text(\"查询\")")
    # Click #tfz-user-name
    page.click("#tfz-user-name")
    # Click text=退出
    # with page.expect_navigation(url="https://dohko.login.internal.tiaofangzi.com/login?redirectURL=http%3A%2F%2Fpublic-mis.tiaofangzi.com"):
    with page.expect_navigation():
        page.click("text=退出")
    # ---------------------
    context.close()
    browser.close()
with sync_playwright() as playwright:
    run(playwright)

# python -m playwright codegen      执行录制命令